import request from '@/router/axios';

// 新增
export const add = (data) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/save',
        method: 'post',
        data
    })
}

//查询列表
export const page = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/page',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}

//查询列表
export const pageTree = ( params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/tree',
        method: 'get',
        params: {
            ...params
        }
    })
}

//详情
export const detail = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/detail',
        method: 'get',
        params
    })
}

//更新
export const update = (data) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/update',
        method: 'post',
        data
    })
}

//更新 JSON
export const updateJson = (data) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/updateJson',
        method: 'post',
        data
    })
}

//删除
export const del = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/deleteByIds',
        method: 'post',
        params: params
    })
}

//发布
export const publish = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page/publish',
        method: 'post',
        params
    })
}

// 获取所有应用
export const getApplicationList = (params) => {
    return request({
        url: '/api/user-api/mx-application/get-list',
        method: 'get',
        params
    })
}

// 获取页面历史记录
export const history_page = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-history/page',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}

// 获取页面详情
export const history_detail = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-history/detail',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}

// 删除历史记录
export const history_del = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-history/delete',
        method: 'post',
        params
    })
}

// 设置为主版本
export const history_setMain = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-history/setMainVersion',
        method: 'post',
        params
    })
}

// 查询发布历史分页
export const publish_page = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-release/page',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}

// 删除发布历史
export const publish_del = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-release/delete',
        method: 'post',
        params
    })
}

// 设为生效版本
export const publish_setMain = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-page-release/active',
        method: 'post',
        params
    })
}

// 查询模板列表
export const templatePage = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/page',
        method: 'get',
        params: {
            ...params
        }
    })
}
// 查询模板详情
export const templateDetail = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/detail',
        method: 'get',
        params: {
            ...params
        }
    })
}

// 批量删除模板
export const templateDelBatch = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/deleteByIds',
        method: 'post',
        params: {
            ...params
        }
    })
}
// 删除模板
export const templateDel = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/delete',
        method: 'post',
        params: {
            ...params
        }
    })
}

// 新增模板
export const templateAdd = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/save',
        method: 'post',
        data: {
            ...params
        }
    })
}
// 更新模板
export const templateUpdate = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-template/update',
        method: 'post',
        params: {
            ...params
        }
    })
}

// 查询组件详情
export const componentDetail = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-component/detail',
        method: 'get',
        params: {
            ...params
        }
    })
}
// 查询组件列表
export const componentPage = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-application-component/page',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}
// 删除组件
export const componentDel = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-component/delete',
        method: 'post',
        params: {
            ...params
        }
    })
}
// 新增组件
export const componentAdd = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-component/save',
        method: 'post',
        data: {
            ...params
        }
    })
}
// 更新组件
export const componentUpdate = (params) => {
    return request({
        url: '/api/lowcode-api/mx-application-component/update',
        method: 'post',
        data: {
            ...params
        }
    })
}

// 数据源分页
export const dataOriginPage = (current, size, params) => {
    return request({
        url: '/api/lowcode-api/mx-data-origin/page',
        method: 'get',
        params: {
            current, size, ...params
        }
    })
}
// 数据源列表
// export const dataOriginList = (params) => {
//     return request({
//         url: '/api/lowcode-api/mx-data-origin/list',
//         method: 'get',
//         params: {
//            ...params
//         }
//     })
// }
// 数据源列表
export const dataOriginList = (params) => {
    return request({
        url: '/api/lowcode-api/mx-operation/getAllOperation',
        method: 'get',
        params: {
           ...params
        }
    })
}
// 新增数据源
export const dataOriginInsert = (params) => {
    return request({
        url: '/api/lowcode-api/mx-data-origin/insert',
        method: 'post',
        data: {
            ...params
        }
    })
}
// 编辑数据源
export const dataOriginUpdate = (params) => {
    return request({
        url: '/api/lowcode-api/mx-data-origin/update',
        method: 'post',
        data: {
            ...params
        }
    })
}

// 查询数据源详情
export const dataOriginDetail = (params) => {
    return request({
        url: '/api/lowcode-api/mx-data-origin/detail',
        method: 'get',
        params: {
            ...params
        }
    })
}

// 删除数据源
export const dataOriginDel = (params) => {
    return request({
        url: '/api/lowcode-api/mx-data-origin/delete',
        method: 'post',
        params: {
            ...params
        }
    })
}

// 上传图片
export const upload = (formData) => {
    return request({
        headers: {
            "Content-Type": "multipart/form-data"
          },
        url: '/api/lowcode-api/mx-application-file/upload',
        method: 'post',
        data:formData
      
    })
}